using System;
using System.Data;
using System.Text;
using System.ComponentModel;
using System.Collections.Generic;

namespace teavch.Utilities.Electrical.Design.Gui.LineDiagram
{
	public partial class Meter : ElectricalSymbol
	{
		private float _hrRation = .9f;
		public string MeterNo { get; set; }

		public Meter()
		{
			InitializeComponent();
		}

		protected override void OnPaint( System.Windows.Forms.PaintEventArgs e )
		{
			base.OnPaint( e );
			this.Paint( e );
		}

		protected override void OnResize( EventArgs e )
		{
			base.OnResize( e );
			ResizeNow( e );
		}

		private void ResizeNow( EventArgs ea )
		{
			this.Refresh();
		}

		private new void Paint( System.Windows.Forms.PaintEventArgs pea )
		{
			int _x1 = 0, _x2 = 0;
			int _y1 = 0, _y2 = 0;

			_x1 = 0;
			_y1 = 0;
			_x2 = ( int ) Math.Ceiling( this.SymbolSize * this._hrRation );
			_y2 = this.SymbolSize;

			this.Width = _x2 + this.BorderWidth;
			this.Height = _y2 + this.BorderWidth;

			System.Drawing.Drawing2D.PathGradientBrush _gBrush = null;
			System.Drawing.Drawing2D.GraphicsPath _gpath = new System.Drawing.Drawing2D.GraphicsPath();

			_gpath.AddRectangle( new System.Drawing.Rectangle( new System.Drawing.Point( _x1, _y1 ), new System.Drawing.Size( _x2, _y2 ) ) );

			if ( this.Fill == true )
			{
				_gBrush = new System.Drawing.Drawing2D.PathGradientBrush( _gpath );
				_gBrush.CenterColor = this.Parent.BackColor;
				_gBrush.SurroundColors = new System.Drawing.Color[] { this.State == SymbolState.On ? System.Drawing.Color.Red : System.Drawing.Color.Lime };
				pea.Graphics.FillPath( _gBrush, _gpath );
			}
			//if ( this.Fill != SymbolFillOption.Half )
			//{
			_gpath.AddLine( _x2, _y2 * .05f, _x1, _y2 * .05f );
			_gpath.AddLine( _x2, _y2 * .1f, _x1, _y2 * .1f );
			_gpath.AddLine( _x2, _y2 * .15f, _x1, _y2 * .15f );
			_gpath.AddLine( _x2, _y2 * .2f, _x1, _y2 * .2f );
			_gpath.AddLine( _x2, _y2 * .25f, _x1, _y2 * .25f );
			_gpath.CloseFigure();
			_gpath.AddLine( _x2, _y2 * .8f, _x1, _y2 * .8f );
		
			//_gpath.AddLine( _x1, _y1, _x2, _y2 );
			//}
			pea.Graphics.DrawPath( this.Pen, _gpath );
		}

	}
}